


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';



class MatchingView extends StatefulWidget {
  const MatchingView({super.key});

  @override
  State<MatchingView> createState() => _MatchingViewState();
}

class _MatchingViewState extends State<MatchingView>  {
  int  isCheck=1;

  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title:Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Column(
              children: [
                TextButton(onPressed: (){
                  setState(() {
                    isCheck=1;
                  });
                }, child:  Text("抢单货源",style: TextStyle (fontWeight:isCheck==1? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: isCheck==1?16.sp:14.sp),),),
                Container(height: 2.h,width: 27.w,color:isCheck==1?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
              ],
            ),
            Column(
              children: [
                TextButton(onPressed: (){
                  setState(() {
                    isCheck=2;
                  });
                }, child:  Text("派单货源",style:TextStyle (fontWeight:isCheck==2? FontWeight.w600:FontWeight.w300,color:Colors.black,fontSize: isCheck==2?16.sp:14.sp),),),
                Container(height: 2.h,width: 27.w,color:isCheck==2?Color.fromRGBO(231, 112, 27, 0.85) : Colors.white,),
              ],
            ),
          ],
        ),
        actions: [
          Badge(
            label:Text("1"),
            child:GestureDetector(
              child: Row(
                children: [

                  Image.asset("lib/Images/RoadLine/消息icon.png",width: 16.w,height: 16.h,),
                  SizedBox(width: 10.w,),
                ],
              ),
              onTap: (){

              },
            ),


          ),
        ],
      ),
      body:ListView(
        children: [

          SizedBox(height: 8.h,),
          Container(
            height:screenSize.height-160.h,
            child:  isCheck==1?SeizeOrdersView():AssignOrdersView(),
          ),

        ],
      ),

    );

  }

}

class SeizeOrdersView extends StatefulWidget {
  const SeizeOrdersView({super.key});

  @override
  State<SeizeOrdersView> createState() => _SeizeOrdersViewState();
}

class _SeizeOrdersViewState extends State<SeizeOrdersView> {
  @override
  Widget build(BuildContext context) {
    return             ListView.separated(

      shrinkWrap:true,
      itemCount: 4,
      itemBuilder: (BuildContext context, int index) {

        return  Container(
          margin: EdgeInsets.only(left: 8.w,right: 8.w),
          height: 230.h,
          decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10))),
          child: Column(
            children: [
              Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    padding: EdgeInsets.only(left:2.w,right: 2.w),
                    height: 18.h,
                    width: 34.w,
                    color: Colors.blue,
                    child: Text("专票",style: TextStyle(color: Colors.white,fontWeight: FontWeight.w600,fontSize: 14.sp),),
                  ),
                  Image.asset("lib/Images/MatchingGoods/待货主选用.png",width:80.w ,height: 20.h,),
                ],
          
              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/RoadLine/绿色圆圈.png",height: 9.h,width: 9.w,),
                  SizedBox(width: 4.w,),
                  Text("苏州",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("-",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("吴中",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  SizedBox(width: 8.w,),
                  Text("今天18:00前装货",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize:14.sp ),),
                ],

              ),
              Row(
                children: [
                  SizedBox(width: 12.w,),
                  Image.asset("lib/Images/MatchingGoods/配货中竖线条.png",width: 1.w,height:20.h,),
                ],
              ),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/RoadLine/红色圆圈.png",height: 9.h,width: 9.w,),
                  SizedBox(width: 4.w,),
                  Text("宁波",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("-",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("北仑",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  SizedBox(width: 8.w,),
                  Text("明天6-12点卸货",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize:14.sp ),),
                ],

              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Text("床单，5-6吨，6方，纸箱",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize: 13.sp),)
                ],
              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Text("2.7/3.8/4.2米 | 依维柯/高栏/平板",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize: 13.sp),)
                ],
              ),
              SizedBox(height: 8.h,),
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  SizedBox(width: 8.w,),
                  Text("100",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 20.sp,fontWeight: FontWeight.w600),),
                  Text("元/趟",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 12.sp,fontWeight: FontWeight.w600),),
                ],
              ),
              SizedBox(height: 8.h,),
             Container(
               margin: EdgeInsets.only(left: 20.w,right: 20.w),
               height: 1.h,
               color: Color.fromRGBO(245, 243, 243, 1),
             ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/login/苹果登录.png",width: 36.w,height: 36.h,),
                  Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          SizedBox(width: 8.w,),
                          Text("王天来",style: TextStyle(color: Colors.black,fontSize: 13.sp,fontWeight: FontWeight.w600),),
                          Container(
                            margin: EdgeInsets.only(left: 2.w),
                            padding: EdgeInsets.only(top: 2.h,bottom: 2.h,left: 4.w,right: 4.w),
                            color:Color.fromRGBO(251, 236, 228, 1) ,
                            height: 14.h,
                            width: 46.w,
                            child: Text("信用4.0星",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 8.sp),),
                          ),
                          SizedBox(width: 45.w,),
                        ],
                      ),
                      Row(
                        children: [
                          SizedBox(width: 8.w,),
                          Text("交易 1210  好评率  99%",style: TextStyle(color:Color.fromRGBO(148, 148, 148, 1),fontSize: 12.sp ),)

                        ],
                      ),

                    ],
                  ),

                ],
              ),
            ],
          ),
        );

      },
      separatorBuilder: (context, index) { //自定义分割线
        return   Container(
          height: 8.h,
        );
      },


    );
  }
}

class AssignOrdersView extends StatefulWidget {
  const AssignOrdersView({super.key});

  @override
  State<AssignOrdersView> createState() => _AssignOrdersViewState();
}

class _AssignOrdersViewState extends State<AssignOrdersView> {
  @override
  Widget build(BuildContext context) {
    return  ListView.separated(

      shrinkWrap:true,
      itemCount: 4,
      itemBuilder: (BuildContext context, int index) {

        return  Container(
          margin: EdgeInsets.only(left: 8.w,right: 8.w),
          height: 230.h,
          decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10))),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    padding: EdgeInsets.only(left:2.w,right: 2.w),
                    height: 18.h,
                    width: 34.w,
                    color: Color.fromRGBO(231, 112, 27, 0.85),
                    child: Text("企业",style: TextStyle(color: Colors.white,fontWeight: FontWeight.w600,fontSize: 14.sp),),
                  ),
                  Image.asset("lib/Images/MatchingGoods/待确认.png",width:80.w ,height: 20.h,),
                ],

              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/RoadLine/绿色圆圈.png",height: 9.h,width: 9.w,),
                  SizedBox(width: 4.w,),
                  Text("苏州",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("-",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("吴中",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  SizedBox(width: 8.w,),
                  Text("今天18:00前装货",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize:14.sp ),),
                ],

              ),
              Row(
                children: [
                  SizedBox(width: 12.w,),
                  Image.asset("lib/Images/MatchingGoods/配货中竖线条.png",width: 1.w,height:20.h,),
                ],
              ),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/RoadLine/红色圆圈.png",height: 9.h,width: 9.w,),
                  SizedBox(width: 4.w,),
                  Text("宁波",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("-",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  Text("北仑",style: TextStyle(color: Colors.black,fontSize:16.sp,fontWeight: FontWeight.w600 ),),
                  SizedBox(width: 8.w,),
                  Text("明天6-12点卸货",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize:14.sp ),),
                ],

              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Text("床单，5-6吨，6方，纸箱",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize: 13.sp),)
                ],
              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Text("2.7/3.8/4.2米 | 依维柯/高栏/平板",style: TextStyle(color: Color.fromRGBO(102, 102, 102, 1),fontSize: 13.sp),)
                ],
              ),
              SizedBox(height: 8.h,),
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  SizedBox(width: 8.w,),
                  Text("100",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 20.sp,fontWeight: FontWeight.w600),),
                  Text("元/趟",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 12.sp,fontWeight: FontWeight.w600),),
                ],
              ),
              SizedBox(height: 8.h,),
              Container(
                margin: EdgeInsets.only(left: 20.w,right: 20.w),
                height: 1.h,
                color: Color.fromRGBO(245, 243, 243, 1),
              ),
              SizedBox(height: 8.h,),
              Row(
                children: [
                  SizedBox(width: 8.w,),
                  Image.asset("lib/Images/login/苹果登录.png",width: 36.w,height: 36.h,),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          SizedBox(width: 8.w,),

                          Text("王天来",style: TextStyle(color: Colors.black,fontSize: 13.sp,fontWeight: FontWeight.w600),),

                          Container(
                            margin: EdgeInsets.only(left: 2.w),
                            padding: EdgeInsets.only(top: 2.h,bottom: 2.h,left: 4.w,right: 4.w),
                            color:Color.fromRGBO(251, 236, 228, 1) ,
                            height: 14.h,
                            width: 46.w,
                            child: Text("信用4.0星",style: TextStyle(color: Color.fromRGBO(231, 112, 27, 1),fontSize: 8.sp),),
                          ),
                          SizedBox(width: 45.w,),
                        ],
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          SizedBox(width: 4.w,),
                          Text("交易 1210  好评率  99%",style: TextStyle(color:Color.fromRGBO(148, 148, 148, 1),fontSize: 12.sp ),)

                        ],
                      )
                    ],
                  ),
                  SizedBox(width: 60.w,),
                  GestureDetector(
                    child: Container(
                      padding: EdgeInsets.only(left: 18.w,right: 18.w,top: 6.h,bottom: 8.h),
                      margin: EdgeInsets.only(left: 8.w,right: 8.w),
                      width: 80.w,
                      height: 30.h,
                      decoration: BoxDecoration(
                          color: Color.fromRGBO(231, 112, 27, 0.85),
                          borderRadius: BorderRadius.all(Radius.circular(20))),

                      child: Text("去确认",style: TextStyle(fontWeight: FontWeight.w600),),
                    ),
                    onTap: (){

                    },
                  ),
                ],
              ),
            ],
          ),
        );

      },
      separatorBuilder: (context, index) { //自定义分割线
        return   Container(
          height: 8.h,
        );
      },


    );
  }
}